<template>
  <div class="page-container">
    <!--面包屑-->
    <div class="breadcrumb">
      <el-breadcrumb separator-class="el-icon-arrow-right">
        <el-breadcrumb-item>会员中心</el-breadcrumb-item>
        <el-breadcrumb-item>会员等级管理</el-breadcrumb-item>
        <el-breadcrumb-item>自定义成长值规则列表</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <!--工具栏-->
    <div class="toolbar">
      <el-form :inline="true" :model="filters" :size="size" ref="filters" >
        <el-row class="search-input">
          <el-row class="times mr30">
            <el-form-item label="创建时间：" prop="startTime">
              <el-date-picker
                v-model="filters.startTime"
                type="datetime"
                placeholder="开始时间"
                format="yyyy-MM-dd HH:mm:ss"
                value-format="yyyy-MM-dd HH:mm:ss"
                clearable
                 @change="changeStartDate"
                :picker-options="startDateDisabled"
              ></el-date-picker>
            </el-form-item>
            <span class="times-to">-</span>
            <el-form-item prop="endTime">
              <el-date-picker
                v-model="filters.endTime"
                type="datetime"
                placeholder="结束时间"
                format="yyyy-MM-dd HH:mm:ss"
                value-format="yyyy-MM-dd HH:mm:ss"
                clearable
                 @change="changeStartDate"
                :picker-options="startDateDisabled"
              ></el-date-picker>
            </el-form-item>
            <el-form-item label="上线时间：" prop="onlineTimeStart">
              <el-date-picker
                v-model="filters.onlineTimeStart"
                type="datetime"
                placeholder="开始时间"
                format="yyyy-MM-dd HH:mm:ss"
                value-format="yyyy-MM-dd HH:mm:ss"
                clearable
                @change="changeStartDateOnline"
                :picker-options="startDateDisabledOnline"
              ></el-date-picker>
            </el-form-item>
            <span class="times-to">-</span>
            <el-form-item prop="onlineTimeEnd">
              <el-date-picker
                v-model="filters.onlineTimeEnd"
                type="datetime"
                placeholder="结束时间"
                format="yyyy-MM-dd HH:mm:ss"
                value-format="yyyy-MM-dd HH:mm:ss"
                clearable
                @change="changeEndDateOnline"
                :picker-options="endDateDisabledOnline"
              ></el-date-picker>
            </el-form-item>
          </el-row>

          <el-row class="times mr30">
            <el-form-item label="开放时间：" prop="openTimeStart">
              <el-date-picker
                v-model="filters.openTimeStart"
                type="datetime"
                placeholder="开始时间"
                format="yyyy-MM-dd HH:mm:ss"
                value-format="yyyy-MM-dd HH:mm:ss"
                clearable
                 @change="changeStartDateOpen"
                :picker-options="startDateDisabledOpen"
              ></el-date-picker>
            </el-form-item>
            <span class="times-to">-</span>
            <el-form-item prop="openTimeEnd">
              <el-date-picker
                v-model="filters.openTimeEnd"
                type="datetime"
                placeholder="结束时间"
                format="yyyy-MM-dd HH:mm:ss"
                value-format="yyyy-MM-dd HH:mm:ss"
                clearable
                @change="changeEndDateOpen"
                :picker-options="endDateDisabledOpen"
              ></el-date-picker>
            </el-form-item>
          
            <el-form-item
              label="规则名称："
              prop="customizeRuleName"
              class="mb30 mr10"
            >
              <el-input
                v-model.trim="filters.customizeRuleName"
                @input="updateVal"
                placeholder="输入规则名称"
                class="w178"
                maxlength="80"
                clearable
              ></el-input>
            </el-form-item>
              <el-form-item prop="obtainMode" label="是否开放：" class="mb30 mr30" >
                <el-select v-model.trim="filters.whetherOpen" clearable class="w178" placeholder="全部">
                  <el-option label="是" value="1"></el-option>
                  <el-option label="否" value="0"></el-option>
                </el-select>
              </el-form-item>
            </el-row>
           
          <!-- </el-row> -->
        </el-row>
        <el-row class="search-button-noborder">
          <el-form-item>
            <kt-button icon="el-icon-search" :label="'搜索'" type="primary" @click="findPageClick(null)" />
          </el-form-item>
          <el-form-item>
            <kt-button :plain="true" :label="'重置'" type="primary" @click="resetForm('filters')" />
          </el-form-item>
          <el-form-item class="addDiyGrowthrulesBtn" v-if="addCusDis">
            <kt-button :label="'添加自定义成长值规则'" type="primary" @click="handleAdd" />
            <span class="addInfo">!</span>
            <img src="../../../assets/explain.png" class="hiddenImg" />
          </el-form-item>
        </el-row>
      </el-form>
    </div>

    <el-table
        :data="tableList"
        :header-cell-style="{ 'color': '#FFF','background-color': '#409EFF','text-align': 'center'}"
        :highlight-current-row="true"
        :max-height="15000"
        :size="'mini'"
        style="width: 100%"
        class="specialTable"
        :border="false"
        v-loading="loading"
      >
        <el-table-column align="center" label="规则名称"  element-loading-text>
          <template slot-scope="scope">
            <span>{{ scope.row.customizeRuleName}}</span>
          </template>
        </el-table-column>
        
        <el-table-column align="center" label="所属组织"  element-loading-text>
          <template slot-scope="scope">
            <span>{{ scope.row.deptName || '-'}}</span>
          </template>
        </el-table-column>
       
        <el-table-column align="center" label="创建时间"  element-loading-text>
          <template slot-scope="scope">
            <span>{{ scope.row.createTime || '-'}}</span>
          </template>
        </el-table-column>
        <el-table-column align="center" label="上线时间"  element-loading-text>
          <template slot-scope="scope">
            <span>{{ scope.row.onlineTime || '-'}}</span>
          </template>
        </el-table-column>
        <el-table-column align="center" label="是否开放给商家/店铺"  element-loading-text>
          <template slot-scope="scope">
            <span v-if="scope.row.whetherOpen == 1">是</span>
            <span v-if="scope.row.whetherOpen == 0">否</span>
          </template>
        </el-table-column>
         <el-table-column align="center" label="开放时间"  element-loading-text>
          <template slot-scope="scope">
            <span>{{ scope.row.openTime || '-'}}</span>
          </template>
        </el-table-column>
        <el-table-column class-name="status-col" align="left" fixed="right" label="操作" width="400"  :render-header="renderHeader">
          <template slot-scope="scope">
            <kt-button v-show="whetherDelete"
              @click="handleDelete(scope.row)" type="text" size="mini" style label="删除"  v-if="scope.row.whetherOnline == 2" perms="mem:customizeGrowth:delete">
            </kt-button>
            <kt-button
              @click="showInfo(scope.row)" type="text" size="mini" style label="查看" perms="mem:customizeGrowth:look">
            </kt-button>
            <kt-button v-show="whetherShowOnline"
              @click="growthOnline(scope.row)" type="text" size="mini" style label="上线" v-if="scope.row.whetherOnline == 2" perms="mem:customizeGrowth:online">
            </kt-button>
            <kt-button v-show="whetherOpen"
              @click="openToMerchant(scope.row)" type="text" size="mini" style label="开发给商家" v-if="scope.row.whetherOpen == 0" perms="mem:customizeGrowth:open">
            </kt-button>
          </template>
        </el-table-column>
      </el-table>
      <!--分页栏-->
      <div class="toolbar" style="padding:10px;">
        <el-pagination
          layout="total, sizes, prev, pager, next, jumper"
          @current-change="currentChange"
          :current-page="filters.start"
          :page-size="filters.limit"
          :total="totalSize"
          style="float:right;"
          :page-sizes="[10, 20, 30, 40]"
          @size-change="sizeChange"
        ></el-pagination>
      </div>


    <!--新增编辑界面-->
    <el-dialog
      :title="'添加自定义成长值规则'"
      :visible.sync="dialogVisible"
      :close-on-click-modal="false"
      @closed="handleClose"
      class="el-dialog-style"
    >
      <el-form
        :model="dataForm"
        :rules="dataFormRules"
        ref="dataForm"
        :size="size"
        label-position="right"
      >
        <el-form-item prop="deptNames" v-show="addDeptOperate" label-width="47px" class="mb30 t_l">
          <span class="color333 font16">所属组织：</span>
          <span :disabled="deptDis" class="color333 font16">{{dataForm.deptNames}}</span>
        </el-form-item>
        <el-form-item class="mb30" prop="deptName" v-show="editDeptOperate"   label-width="47px">
          <span class="color333 font16">所属组织：</span>
          <span :disabled="deptDis" class="color333 font16">{{dataForm.deptName}}</span>
        </el-form-item>
        <el-form-item label="规则名称：" prop="customizeRuleName" label-width="128px" class="mb10">
          <el-input
            v-model.trim="dataForm.customizeRuleName"
            auto-complete="off"
            placeholder="输入规则名称"
            :disabled="checkDis"
            maxlength="20"
            clearable
          ></el-input>
        </el-form-item>
        <p class="mb20 font12 colorE7 pl127">最多输入20个字符</p>
        <el-form-item label="字母简称：" prop="letterAbbreviation" label-width="128px" class="mb10">
          <el-input
            v-model.trim="dataForm.letterAbbreviation"
            auto-complete="off"
            placeholder="输入规则简称,仅可输入字母和数字"
            :disabled="checkDis"
            maxlength="30"
            oninput="value=value.replace(/[^\w\.\/]/ig,'')"
            clearable
          ></el-input>
        </el-form-item>
        <p class="mb20 font12 colorE7 pl127 textWidth200">用于接口对接重要参数，请认真填写，不可重复，最多30个字符</p>
        <el-form-item
          label="是否可同时启用："
          prop="whetherSimultaneouslyEnable"
          class="t_r dialogInput_short labelAlignment mb10"
        >
          <el-radio
            v-model="dataForm.whetherSimultaneouslyEnable"
            label="1"
            :disabled="checkDis"
            class="radioAlignment font16 color333"
          >不可同时启用</el-radio>
          <el-radio
            v-model="dataForm.whetherSimultaneouslyEnable"
            label="2"
            :disabled="checkDis"
            class="radioAlignment font16 color333"
          >可同时启用</el-radio>
        </el-form-item>
        <p class="mb20 font12 colorE7 pl127 textWidth200" v-if="this.dataForm.whetherSimultaneouslyEnable == 1">同一时间同种规则只能启用一个</p>
        <p class="mb20 font12 colorE7 pl127 textWidth200" v-if="this.dataForm.whetherSimultaneouslyEnable == 2">同一时间同种规则可以启用多个</p>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button
          :size="size"
          @click.native="dialogVisible = false"
          type="primary"
          plain
          class="btn"
          v-if="whetherOpe"
        >{{$t('action.cancel')}}</el-button>
        <el-button
          :size="size"
          type="primary"
          @click.native="submitForm"
          :loading="editLoading"
          class="btn"
          v-if="whetherOpe"
        >下一步</el-button>
        <el-button
          :size="size"
          type="primary"
          @click.native="cancelDialog"
          :loading="editLoading"
          class="btn"
          v-if="canselShow"
        >确定</el-button>
      </div>
    </el-dialog>
    <!-- 下一步弹窗 -->
    <el-dialog
      :title="'添加自定义成长值规则'"
      :visible.sync="growthRuleShow"
      :close-on-click-modal="false"
      @closed="handleClose"
    >
      <div class="positionDes">
        <span class="ruleClass font16">
          <img src="../../../assets/success.png" class="successImg" />
          规则创建成功
        </span>
        <img v-bind:src="imgUrl" />
      </div>
      <div class="positionDes">
        <p>1、创建自定义规则 ---- 2、前端进行开发 ---- 3、运营人员确认并操作上线 ---- 4、添加成长值规则</p>
      </div>
      <div class="positionDes">
        <p>注：需技术开发人员完成开发后才可使用，请及时联系相关人员</p>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button :size="size" type="primary" @click.native="actionSure" class="btn">确定</el-button>
      </div>
    </el-dialog>

    <!-- 设置上线时间弹窗 -->

    <el-dialog
      :title="'设置上线时间'"
      :visible.sync="timeDialogShow"
      :close-on-click-modal="false"
      @closed="handleClose"
      class="el-dialog-style"
    >
      <el-form
        :model="dataForm"
        :rules="dataFormRules"
        ref="dataForm"
        :size="size"
        label-position="center"
      >
        <el-form-item label="设置上线时间：">
          <el-date-picker
            v-model="dataForm.onlineTime"
            type="datetime"
            placeholder="上线时间"
            format="yyyy-MM-dd HH:mm:ss"
            value-format="yyyy-MM-dd HH:mm:ss"
            :picker-options="pickerOptions"
            clearable
          ></el-date-picker>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button
          :size="size"
          @click.native="timeDialogShow = false"
          type="primary"
          plain
          class="btn"
        >{{$t('action.cancel')}}</el-button>
        <el-button :size="size" type="primary" @click.native="growthOnlineSure" class="btn">确定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import PopupTreeInput from "@/components/PopupTreeInput";
import JicTable from "@/components/jicComponentGallery/MemberTable";
import KtButton from "@/views/Core/KtButton";
import TableColumnFilterDialog from "@/views/Core/TableColumnFilterDialog";
import { format } from "@/utils/datetime";
import { exportExcel } from "@/utils/excel";
export default {
  components: {
    PopupTreeInput,
    JicTable,
    KtButton,
    TableColumnFilterDialog
  },
  data() {
    return {
      startDateDisabledOnline: {},//开始时间限制
      endDateDisabledOnline: {},//结束时间限制
      startDateDisabledOpen: {},//开始时间限制
      endDateDisabledOpen: {},//结束时间限制
      startDateDisabled: {},//开始时间限制
      endDateDisabled: {},//结束时间限制
      loading:true,
      tableList:[],
      whetherOpen:false,
      searchDeptDis:false,
      addCusDis: false, //添加自定义规则按钮是否显示
      pickerOptions: { disabledDate: this.disabledTime }, //当前时间之前禁用
      timeDialogShow: false, //设置上线时间弹窗
      whetherShowOnline: false, //是否展示上线按钮
      whetherDelete: false,
      whetherOpe: false, //操作按钮是否显示
      canselShow: false, //确定按钮是否显示
      checkDis: false, //是否可编辑
      imgUrl: "",
      childDis: true,
      growthRuleShow: false, //规则创建成功弹窗
      deptOption: [], //所属组织
      memberEdit: true /* 列表栏操作按钮是否显示 */,
      deptDis: true,
      /* 所属组织层级是否展示 */
      addDeptOperate: true,
      editDeptOperate: false,
      /* 新增所属层级 */
      deptTypes: 0,
      deptLevels: "母平台",
      deptLevel: "母平台",
      //当前账号所属组织
      deptNames: null,
      deptName: null,
      operateDis: true,
      //登录账号所属层级
      deptType: localStorage.getItem("deptType"),//当前登录用户所属组织类型
      totalSize: 0,
      size: "small",
      filters: {
        startTime: null,
        endTime: null,
        startTime: null,
        onlineTimeStart: null,
        onlineTimeEnd: null,
        openTimeStart: null,
        openTimeEnd: null,
        customizeRuleName: null,
        deptId: null,
        whetherOpen: null
      },
      columns: [],
      filterColumns: [],
      pageRequest: { pageNum: 1, pageSize: 10 },
      options: {},
      operation: false, // true:新增, false:编辑
      dialogVisible: false, // 新增编辑界面是否显示
      editLoading: false,
      dataFormRules: {
        customizeRuleName: [
          { required: true, message: "请输入规则名称", trigger: "blur" }
        ],
        letterAbbreviation: [
          { required: true, message: "请输入字母简称", trigger: "blur" }
        ],
        growRangeStart: [
          { required: true, message: "请选择是否可同时启用", trigger: "blur" }
        ]
      },
      // 新增编辑界面数据
      dataForm: {
        whetherSimultaneouslyEnable: "1", // 是否可同时启用
        onlineTime: null, //上线时间
        id: null,
        customizeRuleName: "",
        letterAbbreviation: ""
      }
    };
  },
  methods: {

    // 表头添加移上去显示文案
    renderHeader(h, {column}) {
      const inReview = '提示：1、开放给商家店铺后，下级商家店铺即可使用该规则，开放后不可关闭； 2、规则保存成功后不可修改； 3、规则上线后不可删除；'
      return h(
        'div', [
          h('span', column.label),
          h('el-tooltip', {
            effect: 'light',
            props: {
              placement: 'top'
            }
          }, [
            h('div', {
              slot: 'content',
              style: {
                'width': '750px',
                 whiteSpace: 'normal',
                'margin-bottom': '5px'
              }
            }, inReview),
            h('i', {
              class: 'el-icon-warning',
              style: 'color: #ffbf5e;margin-left:5px;'
            })
          ],)
        ]
      )
    },
    changeStartDateOnline: function() {
      var this_ = this;
      this_.endDateDisabledOnline = {
        disabledDate: time => {
          if (this_.filters.onlineTimeStart) {
            return time.getTime() <= new Date(this_.filters.onlineTimeStart).getTime();
          }
        }
      };
    },
    changeEndDateOnline: function() {
      var this_ = this;
      this_.startDateDisabledOnline = {
        disabledDate: time => {
          if (this_.filters.onlineTimeEnd) {
            return time.getTime() >= new Date(this_.filters.onlineTimeEnd).getTime();
          }
        }
      };
    },
    changeStartDateOpen: function() {
      var this_ = this;
      this_.endDateDisabledOpen = {
        disabledDate: time => {
          if (this_.filters.openTimeStart) {
            return time.getTime() <= new Date(this_.filters.openTimeStart).getTime();
          }
        }
      };
    },
    changeEndDateOpen: function() {
      var this_ = this;
      this_.startDateDisabledOpen = {
        disabledDate: time => {
          if (this_.filters.openTimeEnd) {
            return time.getTime() >= new Date(this_.filters.openTimeEnd).getTime();
          }
        }
      };
    },
    changeStartDate: function() {
      var this_ = this;
      this_.endDateDisabled = {
        disabledDate: time => {
          if (this_.filters.startTime) {
            return time.getTime() <= new Date(this_.filters.startTime).getTime();
          }
        }
      };
    },
    changeEndDate: function() {
      var this_ = this;
      this_.startDateDisabled = {
        disabledDate: time => {
          if (this_.filters.endTime) {
            return time.getTime() >= new Date(this_.filters.endTime).getTime();
          }
        }
      };
    },
    // 换页刷新
      currentChange(pageNum) {
        this.pageRequest.pageNum = pageNum;
        this.findPage();
      },
      sizeChange(pageSize) {
        this.pageRequest.pageNum = 1;
        this.pageRequest.pageSize = pageSize;
        this.findPage();
      },
     //点击搜索，页码重置
      findPageClick(){
        this.pageRequest.pageNum = 1;
        this.findPage();
      },
    // 获取分页数据
    findPage: function(data) {
      let this_ = this;
      if (this_.filters == undefined || this_.filters == null) {
        this_.filters = {};
      }
      this_.filters.start = this.pageRequest.pageNum;
      this_.filters.limit = this.pageRequest.pageSize;
      this_.utils.request.queryCustomizeGrowthRule(this_.filters, function(
        res
      ) {
        this_.tableList = res.data.rows;

        this_.totalSize = Number(res.data.total);
        this_.loading=false;
      });
    },

    //左右分页点击
    handlePageChange(params) {
      if (params != null && params.number != null) {
        if (params.number != null) {
          this.pageRequest.pageNum = params.number;
        }

        this.findPage();
      }
    },
    // 换页刷新
    handleSizeChange: function(pageSize) {
      if (pageSize != null) {
        this.pageRequest.pageSize = pageSize.size;
        this.findPage();
      }
    },
    handleClose() {
      this.$refs.dataForm.resetFields();
      this.growthRuleShow = false;
      this.dialogVisible = false;
    },

    // 删除
    handleDelete: function(data) {
      this.$confirm("您确定要删除该规则吗?", "提示", {
        type: "warning",
        closeOnClickModal: false
      }).then(() => {
        var params = {};
        params.id = data.id;

        var this_ = this;
        this.utils.request.delCustomizeGrowthRule(params, function(res) {
          if (res.data == "1") {
            this_.$message({ message: "操作成功", type: "success" });
            this_.findPage();
          } else {
            this_.$message({
              message: "操作失败, " + res.msg,
              type: "error"
            });
          }
        });
      });
    },
    //查看按钮
    showInfo: function(data) {
      this.deptName = data.deptName;
      this.addDeptOperate = false;
      this.editDeptOperate = true;
      this.dialogVisible = true;
      this.canselShow = true;
      this.checkDis = true;
      this.dataForm = data;
      this.dataForm.whetherSimultaneouslyEnable = data.whetherSimultaneouslyEnable + "";
    },
    // 显示新增界面
    handleAdd: function() {
      this.addDeptOperate = true;
      this.editDeptOperate = false;
      this.dialogVisible = true;
      this.operation = true;
      this.canselShow = false;
      this.childDis = false;
      this.whetherOpe = true;
      this.checkDis = false;
      this.dataForm={
        whetherSimultaneouslyEnable: "1", // 是否可同时启用
        onlineTime: null, //上线时间
        id: null,
        customizeRuleName: "",
        letterAbbreviation: "",
        deptNames:JSON.parse(localStorage.getItem('user')).deptName
      }
    },
    // 编辑
    submitForm: function() {
      let this_ = this;
      this.$refs.dataForm.validate(valid => {
        if (valid) {
          let params = Object.assign({}, this_.dataForm);
          this.utils.request.addCustomizeGrowthRule(params, function(res) {
            if (res.data == "1") {
              this_.growthRuleShow = true;
            } else {
              this_.$message({
                message: "操作失败, " + res.msg,
                type: "error"
              });
            }
          });
        }
      });
    },
    //创建成功规则取消
    actionSure() {
      let this_ = this;
      this_.$refs["dataForm"].resetFields();
      this_.growthRuleShow = false;
      this_.dialogVisible = false;
      this_.findPage();
    },

    // 时间格式化
    dateFormat: function(row, column, cellValue, index) {
      return format(row[column.property]);
    },
    // 处理表格列过滤显示
    displayFilterColumnsDialog: function() {
      this.$refs.tableColumnFilterDialog.setDialogVisible(true);
    },
    // 处理表格列过滤显示
    handleFilterColumns: function(data) {
      this.filterColumns = data.filterColumns;
      this.$refs.tableColumnFilterDialog.setDialogVisible(false);
    },
    // 处理表格列过滤显示
    initColumns: function() {
      this.columns = [
        { prop: "customizeRuleName", label: "规则名称", minWidth: 100 },
        { prop: "deptName", label: "所属组织", minWidth: 100 },
        { prop: "createTime", label: "创建时间", minWidth: 120 },
        {
          prop: "onlineTime",
          label: "上线时间",
          minWidth: 120,
          formatter: function(row, column, cellValue, index) {
            if (cellValue == null) {
              return "-";
            } else {
              return row.onlineTime;
            }
          }
        },
        {
          prop: "whetherOpen",
          label: "是否开放给商家/店铺",
          minWidth: 120,
          formatter: function(row, column, cellValue, index) {
            if (cellValue == 1) {
              return "是";
            } else if (cellValue == 0) {
              return "否";
            }
          }
        },
        {
          prop: "openTime",
          label: "开放时间",
          minWidth: 120,
          formatter: function(row, column, cellValue, index) {
            if (cellValue == null) {
              return "-";
            } else {
              return row.openTime;
            }
          }
        }
      ];
      var temp = [];
      $.each(this.columns, function(key, val) {
        temp.push(val);
      });
      this.filterColumns = temp;
    },
    resetForm(formName) {
      //需要校验的key
      let keys = [
        "startTime",
        "endTime",
        "onlineTimeStart",
        "onlineTimeEnd",
        "openTimeStart",
        "openTimeEnd",
        "customizeRuleName",
        "deptId",
        "whetherOpen"
      ];
      let boo = this.seachTableUtils.checkFromIsNull(this.filters, keys);
      if (!boo) {
        return;
      }
      this.filters = {
        startTime: null,
        endTime: null,
        onlineTimeStart: null,
        onlineTimeEnd: null,
        openTimeStart: null,
        openTimeEnd: null,
        customizeRuleName: null,
        deptId: null,
        whetherOpen: null
      };
      this.findPage();
    },
    //查询当前登录账号适用范围
    getGrowhtScopeInfo() {
      let this_ = this;
      this.utils.request.getGrowhtScopeInfo({}, function(res) {
        if (this_.deptTypes == 2) {
          //当前登录账号是商家账号,
          if (res.scopeApplication == 1) {
            //适用范围是商家
            this_.operateDis = true;
            this_.memberEdit = true;
          } else if (res.scopeApplication == 2) {
            //适用范围是店铺，
            this_.operateDis = false;
            this_.memberEdit = false;
          }
        } else if ((this_.deptTypes = 3)) {
          //当前登录账号是店铺账号
          if (res.scopeApplication == 1) {
            //适用范围是商家
            this_.operateDis = false;
            this_.memberEdit = false;
          } else if (this_.scopeApplication == 2) {
            //适用范围是店铺
            this_.operateDis = true;
            this_.memberEdit = true;
          }
        }
      });
    },
    //查询当前登录账号所属组织
    getDeptNameByDeptId() {
      let this_ = this;
      this_.utils.request.getDeptNameByDeptId({}, function(res) {
        this_.deptNames = res.data;
      });
    },
    //获取子平台列表
    queryDeptOption() {
      let query = {};
      let this_ = this;
      query.deptType = 1;
      this_.utils.request.queryDeptList(query, function(res) {
        if (res.code == "0000") {
          this_.deptOption = res.data;
        }
      });
    },
    //input框视图强制刷新
    updateVal() {
      this.$forceUpdate();
    },
    cancelDialog() {
      this.dialogVisible = false;
      this.findPage();
    },
    //上线按钮
    growthOnline(data) {
      let this_ = this;
      this_.timeDialogShow = true;
      this_.dataForm.id = data.id;
      this_.dataForm.onlineTime = new Date();
    },
    //设置上线时间确认按钮
    growthOnlineSure() {
      let this_ = this;
      let params = {};
      params.id = this_.dataForm.id;
      params.onlineOrOpen = 1;
      params.onlineTime = this_.dataForm.onlineTime;
      this_.utils.request.growthOnline(params, function(res) {
        if (res.data == 1) {
          this_.$message({
            message: "上线成功, " + res.msg,
            type: "success"
          });
          this_.timeDialogShow = false;
          this_.findPage();
        } else {
          this_.$message({
            message: "上线失败, " + res.msg,
            type: "error"
          });
          this_.timeDialogShow = false;
          this_.findPage();
        }
      });
    },
    //开放给商家按钮
    openToMerchant(data) {
      this.$confirm("您确定要将该规则开放给商家店铺？开放后不可修改", "提示", {
        type: "warning",
        closeOnClickModal: false
      })
        .then(() => {
          let this_ = this;
          if (data.whetherOnline == 2) {
            this_.$message({
              message: "请先上线此规则再进行开放操作",
              type: "error"
            });
          } else {
            let params = {};
            params.id = data.id;
            params.onlineOrOpen = 2;
            this_.utils.request.openToMerchant(params, function(res) {
              if (res.data == 1) {
                this_.$message({
                  message: "开放成功, " + res.msg,
                  type: "success"
                });
                this_.findPage();
              } else {
                this_.$message({
                  message: "开放失败, " + res.msg,
                  type: "error"
                });
                this_.findPage();
              }
            });
          }
        })
        .catch(() => {});
    },
    disabledTime(time) {
      return time.getTime() < Date.now() - 8.64e7;
    },

    //查询当前登录账号所属层级
    getDeptType() {
      let this_ = this;
      this.utils.request.getDeptType({}, function(res) {
        if (res.deptType == 0) {
          this_.operateDis = true;
          this_.addCusDis = true;
          this_.searchDeptDis = true
        } else {
          this_.operateDis = false;
          this_.addCusDis = false;
          this_.searchDeptDis = false
        }
      });
    }
  },

  mounted() {
    this.findPage();
    this.getGrowhtScopeInfo();
    this.getDeptNameByDeptId();
    this.getDeptType();
  }
};
</script>

<style lang='scss' scoped>
.dialogInput {
  text-align: left;
  /deep/ .el-input {
    width: 400px;
  }
  /deep/ .el-input__inner {
    width: 400px !important;
  }
}
.dialogInput_short {
  text-align: left;
  /deep/ .el-input {
    width: 130px;
    margin-right: 10px;
  }
  /deep/ .el-input__inner {
    width: 130px !important;
  }
  /deep/ .el-form-item--small.el-form-item {
    margin-bottom: 0;
  }
}
.connection {
  display: inline-block;
  height: 32px;
  line-height: 32px;
}
.growRangeStart,
.growRangeEnd {
  display: inline-block;
  width: 130px;
}
.positionDes {
  text-align: center;
  margin-top: 2%;
}
.ruleClass {
  font-size: 30px;
}
.addDiyGrowthrulesBtn {
  position: relative;
  /deep/ .el-button {
    padding: 0 35px 0 15px !important;
  }
  .addInfo {
    display: inline-block;
    width: 20px;
    height: 20px;
    color: #fff;
    background-color: orange;
    font-size: 12px;
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    border-radius: 20px;
    text-align: center;
    line-height: 20px;
    cursor: pointer;
  }
  .addInfo:hover + .hiddenImg {
    display: block;
    transition: all 30s;
  }
  .hiddenImg {
    width: 400px;
    height: 400px;
    position: absolute;
    top: 40px;
    right: 0px;
    z-index: 9999;
    border: 1px solid #000;
    display: none;
  }
}
.infoTips {
  width: 20px;
  height: 20px;
  position: absolute;
  top: 66%;
  right: 6%;
  z-index: 9999;
  background-color: orange;
  border-radius: 10px;
  color: #fff;
  line-height: 20px;
  text-align: center;
}
.search-button {
  margin-bottom: 20px !important;
}
.tips {
  span {
    display: inline-block;
    margin-bottom: 6px;
  }
}
.search-input {
  .times {
    .times-to {
      padding: 0 10px;
      height: 32px;
      line-height: 32px;
      color: #999;
      display: inline-block;
    }
    /deep/ .el-input {
      width: 208px !important;
      /deep/ .el-input__inner {
        width: 208px !important;
      }
    }
  }
}
.mb20 {
  margin-bottom: 20px;
}
.colorE7 {
  color: #ffbf5e !important;
}
.mb10 {
  margin-bottom: 10px !important;
}
.pl127 {
  padding-left: 127px !important;
}
.textWidth200 {
  width: 200px !important;
}
.font10 {
  font-size: 10px !important;
}
</style>
